from rest_framework import serializers

from goods.models import SKU
from orders.models import OrderInfo, OrderGoods


class SkuSerializer(serializers.ModelSerializer):
    class Meta:
        model = SKU
        fields=('name','default_image')

class OrderGoodsSerializer(serializers.ModelSerializer):
    sku = SkuSerializer(read_only=True)
    class Meta:
        model = OrderGoods
        fields = "__all__"

class OrderInfoSerializer(serializers.ModelSerializer):
    user = serializers.StringRelatedField(read_only=True)
    skus = OrderGoodsSerializer(read_only=True,many=True)
    class Meta:
        model = OrderInfo
        fields = "__all__"
